package org.gem.example.strategy;

import java.math.BigDecimal;

/**
 * 满减策略
 */
public class FullReduction implements DiscountStrategy {
    private final BigDecimal threshold;
    private final BigDecimal reduction;

    public FullReduction(double threshold, double reduction) {
        this.threshold = new BigDecimal(threshold);
        this.reduction = new BigDecimal(reduction);
    }

    public BigDecimal applyDiscount(BigDecimal originalPrice) {
        return originalPrice.compareTo(threshold) >= 0 ? originalPrice.subtract(reduction) : originalPrice;
    }
}